Ext.BLANK_IMAGE_URL='/wsd/image/page/s.gif';
Ext.onReady(function(){
	
	var titleField = new Ext.form.TextField({
		fieldLabel:'标题',
		width:400,
		emptyText:'请输入文章标题',
		allowBlank:false,
		blankText:'文章标题不能为空',
		name:'article.ATitle',
		msgTarget:'under'
	})
	var typeCombo = new Ext.form.ComboBox({
		fieldLabel:'文章类别',
		mode:'local',
		name:'text',
		triggerAction:'all',
		valueField:'article.AModel',
		displayField:'AModel',
		value:1,
		editable:false,
		store:new Ext.data.SimpleStore({
			fields:['article.AModel','AModel'],
			data:[
				['1','公司新闻'],
				['2','行业资讯']
			]
		})
	})
	var contentField = new Ext.form.HtmlEditor({
		fieldLabel:'内容',
		widt:800,
		height:300,
		name:'article.AContent',
		autoScroll:true
	})
	var postBtn = new Ext.Button({
		text:'发布',
		handler:post
	})
	var resetBtn = new Ext.Button({
		text:'重置'
	})
	//中间主面板
	var articleForm = new Ext.FormPanel({
		region:'center',
		frame:true,
		autoScroll:true,
		items:[titleField,typeCombo,contentField],
		buttons:[postBtn,resetBtn]
	})
	
	var viewport = new Ext.Viewport({
		layout : 'border',
		frame:true,
		items : [articleForm]
	});
	/**
	 * 发布文章
	 */
	function post(){
		if(articleForm.getForm().isValid()){
			var model = typeCombo.getValue();
			var content = contentField.getValue().trim();
			articleForm.getForm().submit({
				url:'admin/article_post.action',
				params:{
					'article.AModel':model
				},
                waitMsg: '系统正在处理，请稍后……',
                success: function(fp, o){
                	Ext.Msg.alert('系统信息',"添加成功");
                },
                failure:function(fp, o){
                	Ext.Msg.alert('系统信息',o.result.msg);
                }
			})
		}
	}
	
});